﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace Service.Infrastructure.Utils
{
    public static class SecurityHelper
    {
        public static string ToMd5(this string source)
        {
            using (var md5 = new MD5CryptoServiceProvider())
            {
                if (string.IsNullOrEmpty(source)) return string.Empty;

                var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(source));
                var result = BitConverter.ToString(hash).Replace("-", "");

                return result;
            }
        }
    }
}
